<?php
/**
 * Global PSA config file.
 * See comments in the file for detailed description of global settings.
 * You can make file named <kbd>config_override.php</kbd> in the same directory 
 * and override values from this file. It is useful if you update your PSA directory
 * from SVN repository.
 * 
 * 
 * LICENSE:
 * 
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with This library. If not, see <{@link http://www.gnu.org/licenses/}>.
 *
 * @link http://code.google.com/p/phpstartapp/
 * @author Bojan Mauser <bmauser@gmail.com>
 * @copyright Bojan Mauser 2009
 * @package psa
 * @version $Id: config.php 464 2009-03-24 00:30:12Z bmauser $
 */


/**
 * PDO settings - database connection settings
 */
$PSA_CFG['pdo']['username'] = 'databaseUser';
$PSA_CFG['pdo']['password'] = 'databasePass';

// for MySQL:
//$PSA_CFG['pdo']['dsn']      = "mysql:host=localhost;port=3306;dbname=databaseName";
//$PSA_CFG['pdo']['driver_options'] = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);

// for PostgreSQL:
//$PSA_CFG['pdo']['dsn']      = "pgsql:host=localhost;port=5432;dbname=databaseName";
//$PSA_CFG['pdo']['driver_options'] = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);


/**
 * Develop mode.
 * If true, some settings optimized for developing will be set. On production site you 
 * MUST set this to false.
 * - Smarty's force_compile option set to true 
 *   (see {@link http://www.smarty.net/manual/en/variable.force.compile.php})
 * - logs turned on
 * - error reporting set to E_ALL
 * - plugins are registered on every request
 * - $_SESSION['psa_plugins'] value is always retrieved from the database (this session variable 
 *   holds data about registered plugins).
 * - warnings are shown if a query against the database fails
 * - some information about each request will be available through Psa_Registry object in 
 *   psa_request_info member array.
 *   This information can be nicely shown on web page by including html code that returns 
 *   psa_request_info_html() function. It can be very useful for debugging and while developing. 
 *   Read more in documentation for psa_request_info_html() function.
 */
$PSA_CFG['develop_mode'] = true;


/**
 * Web path to folder where index.php is if application is not in web server root directory.
 * This can be used in router to correctly parse url to find out what is controller name.
 * Leave empty ('') if your application is in the web server root folder.
 * Example: '/webroot/myapp'
 * I set this value without '/' at the end, but that is at your choice and how will you use it
 * later, for example in router.
 */
$PSA_CFG['folders']['basedir_web'] = '';


/**
 * Plugin locations.
 * Folders in $PSA_CFG['folders']['plugins'] array will be recursively checked for plugins 
 * on plugin registration. You can add more locations for plugins classes by adding elements 
 * to this array. Paths in this array must be relative to PSA main folder.
 */
//$PSA_CFG['folders']['plugins'][] = '../plugins';
//$PSA_CFG['folders']['plugins'][] = '../my_plugins';


/**
 * Router location. Folder where is Router.php file.
 * If this is not set router will be searched in first plugin location.
 * Relative to PSA main folder without '/' at the end.
 */
//$PSA_CFG['router_location'] = '';


/**
 * Plugin types location.
 * Folders in $PSA_CFG['folders']['plugin_types'] array will be checked for classes that
 * defines PSA plugins. Names of those classes must start with 'Psa_Plugin_' 
 * You can add more locations for plugin types classes by adding elements 
 * to this array. Paths in this array must be relative to PSA main folder.
 */
$PSA_CFG['folders']['plugin_types'][] = 'plugin_classes';


/**
 * Folders for Smarty templates. Relative from PSA main folder. See http://smarty.php.net/ for details.
 */
$PSA_CFG['folders']['smarty']['cache_dir']    = '../templates/smarty/cache';       // must be writable to web server
$PSA_CFG['folders']['smarty']['config_dir']   = '../templates/smarty/configs';
$PSA_CFG['folders']['smarty']['compile_dir']  = '../templates/smarty/templates_c'; // must be writable to web server
$PSA_CFG['folders']['smarty']['template_dir'] = '../templates';


/**
 * Folder for Dully templates. Uncomment if you use Dully templates
 */
// $PSA_CFG['folders']['dully']['template_dir'] = 'templates';


/**
 * If true profile log will be enabled. 
 * If you enable this, profile log will be written into psa_profile_log database table by default 
 * (see settings below). Enabling this will greatly increase number of queries against the database 
 * on every request. You should enable this in testing and profiling process.
 * When you collect appropriate amount of data in profile log you can run various sql queries to get 
 * interesting data about your application like which methods are mostly invoked, which takes the most 
 * execution time and are candidates for optimization.
 * Logging must be enabled for this to work (see ['logging']['max_log_level'] option below).
 * 
 * NOTE: psa_main() methods from router and controller plugins will take the most time 
 * 	 because from them are all other methods called thus their time will be sum of times.
 * 
 * NOTE: If property $psa_no_profile_log is set in plugin object (class), profile log will be disabled for
 *       all methods in this class. You can do that for Router or Controller if you don't want to have them 
 *       in profile log.
 */
$PSA_CFG['profile_log'] = 0;


/**
 * Logging. If enabled (see max_log_level value below) some PSA activity will be logged.
 * This values are used by Psa_Logger class which you can extend for your customized logging in your plugins.
 * You can add more storages to $PSA_CFG['logging']['storage'] array for your custom logs.
 */

// Log level:
//  0 - logging disabled, 
//  1 - only exceptions, errors, warnings
//  2 - all in level 1 and some activities like authorizations, user/group data saving, password changing...
$PSA_CFG['logging']['max_log_level'] = 2;

// Log storage:
// - storage type can be 'database' or 'file'. PSA writes log messages in storage named 'psa_default'.
// - storage target can be database table name or or full filesystem path for the log file. 
//   If is a file, web server must have write permission on the specified file.
// NOTE: If you want to write logs to different database than one mentioned in $PSA_CFG['pdo']['dsn']
//       write target as 'database.psa_log'. Also database user used to connect to database must have
//       permission to write to that database.
$PSA_CFG['logging']['storage']['psa_default']['type']   = 'database';
$PSA_CFG['logging']['storage']['psa_default']['target'] = 'psa_log'; // for PSA default log
$PSA_CFG['logging']['storage']['psa_profile']['type']   = 'database';
$PSA_CFG['logging']['storage']['psa_profile']['target'] = 'psa_profile_log'; // for PSA profile log.
//$PSA_CFG['logging']['storage']['my_storage']['type']   = 'database';
//$PSA_CFG['logging']['storage']['my_storage']['target'] = 'my_log_table';

// Single or multiple lines in log messages.
// If logging storage type is 'file' should log messages be written with new lines (more lines per 
// one log message which is more readable) or one log message per line.
$PSA_CFG['logging']['more_lines'] = true;

// Time format for log message. 
// This is used only when logging to file. See date() function in PHP manual for details.
$PSA_CFG['logging']['time_format'] = 'd.m.Y H:i:s';

// Should new database connection be opened for writing logs to database.
// Set this to 1 if you use database transactions and you want to write logs to database from inside 
// transactions that can be rollbacked.
// NOTE: If you enable this option and use logging and profile logging,
//       on every request 3 database connections will be opened.
$PSA_CFG['logging']['new_database_connection'] = 0;


/**
 * PSA main directory (this is also set in front_controler.php thus we have 'if' here)
 */
if(!isset($PSA_CFG['folders']['basedir']))
	$PSA_CFG['folders']['basedir'] = dirname(__FILE__);


/**
 * User passwords hashing method. This value must be valid argument for hash() PHP function.
 */
$PSA_CFG['password_hash'] = 'sha256';


/**
 * Database tables names.
 */
$PSA_CFG['database']['table']['user'] = 'psa_user';
$PSA_CFG['database']['table']['group'] = 'psa_group';
$PSA_CFG['database']['table']['user_in_group'] = 'psa_user_in_group';
$PSA_CFG['database']['table']['plugin'] = 'psa_plugin';


/**
 * Config file that will override settings in this file.
 */
if(file_exists($PSA_CFG['folders']['basedir'] . '/config_override.php'))
	include_once $PSA_CFG['folders']['basedir'] . '/config_override.php';

